home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / tcp_ip / rip2 / rip.h < prev    next >
C/C++ Source or Header  |  1993-09-28  |  7KB  |  213 lines

  1. #ifndef    _RIP_H
  2. #define    _RIP_H
  3.  
  4. /* Routing Information Protocol (RIP)
  5.  *
  6.  *    This code is derived from the 4.2 BSD version which was
  7.  * used as a spec since no formal specification is known to exist.
  8.  * See RFC 1009, Gateway Requirements, for more details. AGB 4-29-88
  9.  *
  10.  * The draft RIP RFC was used to develop most of this code. The above
  11.  * referred to the basics of the rip_recv() function of RIP.C. The RIP
  12.  * RFC has now been issued as RFC1058. AGB 7-23-88
  13.  *
  14.  * Substantially rewritten and integrated into NOS 9/1989 by KA9Q
  15.  *
  16.  * Mods by PA0GRI
  17.  *
  18.  *    Changes Copyright (c) 1993 Jeff White - N0POY, All Rights Reserved.
  19.  *    Permission granted for non-commercial copying and use, provided
  20.  *    this notice is retained.
  21.  *
  22.  * Rehack for RIP-2 (RFC1388) by N0POY 4/1993
  23.  *
  24.  * Beta release 9/8/93 V0.91
  25.  *
  26.  *
  27.  */
  28.  
  29. #ifndef    _MBUF_H
  30. #include "mbuf.h"
  31. #endif
  32.  
  33. #ifndef    _IFACE_H
  34. #include "iface.h"
  35. #endif
  36.  
  37. #ifndef _UDP_H
  38. #include "udp.h"
  39. #endif
  40.  
  41. #define  RIP_VERSION_0           0
  42. #define  RIP_VERSION_1           1
  43. #define  RIP_VERSION_2           2
  44. #define  RIP_VERSIONS            3
  45.  
  46. #define  RIP_METRIC_UNREACHABLE  16
  47. #define  RIP_INFINITY            RIP_METRIC_UNREACHABLE
  48. #define  RIP_METRIC_SHUTDOWN     (RIP_METRIC_UNREACHABLE - 1)
  49.  
  50. #define  RIP_AUTH_SIZE           16
  51.  
  52. #define  RIP_PKTSIZE             512
  53. #define  RIP_HEADER              4
  54. #define  RIP_ENTRY               20
  55. #define  RIP_ADDR_MC             0xe0000009  /* 224.0.0.9 */
  56. #define  RIP_PORT                520
  57. #define  RIP_HOP                 1        /* Minimum hop count when passing through */
  58.  
  59. #define  RIP_AF_UNSPEC           0        /* Unknown family */
  60. #define  RIP_AF_INET             2        /* IP Family */
  61. #define  RIP_AF_AUTH             0xffff   /* Authetication header */
  62. #define  RIP_NO_AUTH             "NONE"   /* No authentication */
  63.  
  64. #define  RIP_AUTH_NONE           0
  65. #define  RIP_AUTH_SIMPLE         2
  66. #define  RIP_TTL                 240      /* Default time-to-live for an entry */
  67.  
  68. /*
  69.  * Packet types.
  70.  */
  71.  
  72. #define  RIPCMD_REQUEST          1        /* want info */
  73. #define  RIPCMD_RESPONSE         2        /* responding to request */
  74. #define  RIPCMD_TRACEON          3        /* turn tracing on */
  75. #define  RIPCMD_TRACEOFF         4        /* turn it off */
  76. #define  RIPCMD_POLL             5        /* like request, but anyone answers */
  77. #define  RIPCMD_POLLENTRY        6        /* like poll, but for entire entry */
  78. #define  RIPCMD_MAX              7
  79.  
  80.  
  81. /* RIP Flags */
  82.  
  83. #define  RIP_SPLIT               0x01     /* Do split horizon processing */
  84. #define  RIP_US                  0x02     /* Include ourselves in the list */
  85. #define  RIP_BROADCAST           0x04     /* Broadcast RIP packets */
  86. #define  RIP_MULTICAST           0x08     /* Multicast RIP packets */
  87. #define  RIP_POISON              0x10     /* Poisoned reverse on */
  88. #define  RIP_AUTHENTICATE        0x20     /* Authenticate each packet */
  89.  
  90.  
  91. /* RIP statistics counters */
  92. struct rip_stat {
  93.    struct version_data {
  94.       int32 output;        /* Packets sent */
  95.       int32 rcvd;          /* Packets received */
  96.       int32 request;       /* Number of request packets received */
  97.       int32 response;      /* Number of responses received */
  98.       int32 unknown;       /* Number of unknown command pkts received */
  99.    } vdata[RIP_VERSIONS];
  100.    int32 version;          /* Number of version errors */
  101.    int32 addr_family;      /* Number of address family errors */
  102.    int32 refusals;         /* Number of packets dropped from a host
  103.                               on the refuse list */
  104.    int32 wrong_domain;     /* Refused due to wrong domain for interface */
  105.    int32 auth_fail;        /* Authentication failures */
  106.    int32 unknown_auth;     /* Unknown authentication type */
  107. };
  108.  
  109. struct rip_list {
  110.    struct rip_list *prev;
  111.    struct rip_list *next;    /* doubly linked list */
  112.  
  113.    /* address to scream at periodically:
  114.     * this address must have a direct network interface route and an
  115.     * ARP entry for the appropriate  hardware broadcast address, if approp.
  116.     */
  117.    int32 dest;
  118.  
  119.    /* basic rate of RIP clocks on this net interface */
  120.    int32 interval;
  121.  
  122.    struct timer rip_time;     /* time to output next on this net. iface */
  123.  
  124.     /* the interface to transmit on  and receive from */
  125.    struct iface *iface;
  126.    char  rip_version;         /* Type of RIP packets */
  127.    int16 flags;
  128.    int16 domain;              /* Routing domain in */
  129.    int16 route_tag;           /* Route tag to send */
  130.    int32 proxy_route;         /* For Proxy RIP-2, 0 if none */
  131.    char rip_auth_code[RIP_AUTH_SIZE+1];
  132.                               /* Authentication code to send */
  133. };
  134. #define  NULLRL   (struct rip_list *)0
  135.  
  136. struct rip_refuse {
  137.    struct rip_refuse *prev;
  138.    struct rip_refuse *next;
  139.    int32    target;
  140. };
  141. #define  NULLREF  (struct rip_refuse *)0
  142.  
  143. struct rip_auth {
  144.    struct rip_auth *prev;
  145.    struct rip_auth *next;
  146.    char *ifc_name;            /* Name of the interface */
  147.    int16 domain;              /* Check against valid routing domain */
  148.    char rip_auth_code[RIP_AUTH_SIZE+1];
  149.                               /* Authentication password accepted */
  150. };
  151. #define  NULLAUTH (struct rip_auth *)0
  152. #define  DEFAULTIFC     "DEFAULT"
  153.  
  154. /* Host format for the RIP-II header */
  155.  
  156. struct rip_head {
  157.    unsigned char rip_cmd;
  158.    unsigned char rip_vers;
  159.    unsigned short rip_domain;
  160. };
  161.  
  162. /* Host format of a single entry in a RIP response packet */    
  163. struct rip_route {
  164.    int16 rip_family;
  165.    int16 rip_tag;
  166.    int32 rip_dest;
  167.    int32 rip_dest_mask;
  168.    int32 rip_router;
  169.    int32 rip_metric;
  170. };
  171.  
  172. /* Host format of an authentication packet */
  173. struct rip_authenticate {
  174.    int16 rip_family;
  175.    int16 rip_auth_type;
  176.    char  rip_auth_str[RIP_AUTH_SIZE];
  177. };
  178.  
  179. /* RIP primitives */
  180.  
  181. int rip_init __ARGS((void));
  182. void rt_timeout __ARGS((void *s));
  183. void rip_trigger __ARGS((void));
  184. int rip_add __ARGS((int32 dest,int32 interval,char flags, char version,
  185.    char authpass[RIP_AUTH_SIZE], int16 domain, int16 route_tag, int32 proxy));
  186. int riprefadd __ARGS((int32 gateway));
  187. int riprefdrop __ARGS((int32 gateway));
  188. int ripreq __ARGS((int32 dest,int16 replyport,int16 version));
  189. int rip_drop __ARGS((int32 dest,int16 domain));
  190. int ripauthdrop __ARGS((char *ifcname,int16 domain));
  191. int ripauthadd __ARGS((char *ifcname,int16 domain,char *password));
  192. int nbits __ARGS((int32 target));
  193. void pullentry __ARGS((struct rip_route *ep,struct mbuf **bpp));
  194. void rip_shout __ARGS((void *p));
  195.  
  196. /* RIP Definition */
  197.  
  198. extern int16 Rip_trace;
  199. extern FILE *Rip_trace_file;
  200. extern char *Rip_trace_fname;
  201. extern int16 Rip_merge;
  202. extern int32 Rip_ttl;
  203. extern int16 Rip_ver_refuse;
  204. extern int16 Rip_default_refuse;
  205. extern struct rip_stat Rip_stat;
  206. extern struct rip_list *Rip_list;
  207. extern struct rip_refuse *Rip_refuse;
  208. extern struct rip_auth *Rip_auth;
  209. extern struct udp_cb *Rip_cb;
  210.  
  211. #endif    /* _RIP_H */
  212.  
  213.